
<?php $c_id = $this->uri->rsegment(3); 
    $cs = _get_category_parent_id($c_id);
    
    if(count($cs)>0){
        
?>
<div class="products">
    <?php foreach($cs as $c){ 
        $cat_name = $c->cat_name;
        $cat_name = $this->_global->_unserialize($cat_name); 
        $cat_alias = $this->_global->_unserialize($c->cat_alias);
      
        $posts = _get_product($c->cat_id);  
    ?>
    <div class="cat-title"><h2><?php echo anchor('shop/'.$cat_alias[$this->session->userdata('lan')]['alias'].'-'.$c->cat_id,$cat_name[$this->session->userdata('lan')]['title']) ?></h2></div>
    <?php 
if(!empty($posts)):
?>
<?php 
$i=0;

foreach($posts as $post): 

    $product_name = $this->_global->_unserialize($post->product_name);
    $product_desc = $this->_global->_unserialize($post->product_desc);
    
    $alias = $this->_global->_unserialize($post->product_alias);
    if(isset($alias[$this->session->userdata('lan')]['alias']))
        $alias = $alias[$this->session->userdata('lan')]['alias'];
    else
        $alias = '';
    
    if(isset($product_name[$this->session->userdata('lan')]['product_name']))
        $product_name = $product_name[$this->session->userdata('lan')]['product_name'];
    else
        $product_name = '';
        if(isset($product_desc[$this->session->userdata('lan')]['product_desc']))
        $product_desc = $product_desc[$this->session->userdata('lan')]['product_desc'];
    else
        $product_desc = '';
    $detail = $this->_global->_unserialize($post->product_detail);
    $color = current($detail['options']['colors']);
    if(!isset($_GET['mode']) || $_GET['mode']=='table'){
?><div class="item">
            <div class="price-button"><?php echo $post->price_export?> vnd</div>
                	<?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'<img alt="'.$product_name.'" src="'.$this->config->item('cdn_url').'exec/timthumb.php?src='.base_url().current($color['images']).'&w=175&h=175&zc=1"/>','title="'.$product_name.'"') ?>
                    <h3><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,$product_name) ?></h3>
                    <p>Nhà cung cấp : <strong><?php echo $post->brand_tag; ?></strong></p>
                    <div class="button"><span><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'Xem chi tiết')?></span></div>
            </div>

<?php
}
endforeach;
?><div class="clear"></div>
<?php
endif;
}
?>
<div class="clear"></div>
</div>
<?php
    
    }else{
?>
<div class="products">

<div class="cat-title" style="margin-bottom: 5px;">
                <h1><?php echo $cat_name ?></h1>
            </div>
<div class="paging">Có tổng cộng <?php echo count($posts); ?> sản phẩm
                	<?php echo $pages ?>
                </div><div class="clear"></div>
<div class="paging">
                	<ul class="viewas">
                        <li style="position: relative;top:-4px">Xem dưới dạng:</li>
                        <li><a href="/<?php echo $this->uri->uri_string?>.html?mode=table" class="viewtb <?php echo isset($_GET['mode']) && $_GET['mode']=='table'?'viewtb-active':'' ?>" title="Xem dưới dạng bảng">Table</a></li>
                        <li><a href="/<?php echo $this->uri->uri_string?>.html?mode=list" class="viewlist <?php echo isset($_GET['mode']) && $_GET['mode']=='list'?'viewlist-active':'' ?>"  title="Xem dưới dạng danh sách">List</a></li>
                        
                    </ul>
                </div><div class="clear"></div>
<?php 
if(!empty($posts)):
?>

<?php 
$i=0;

foreach($posts as $post): 

    $product_name = $this->_global->_unserialize($post->product_name);
    $product_desc = $this->_global->_unserialize($post->product_desc);
    
    $alias = $this->_global->_unserialize($post->product_alias);
    if(isset($alias[$this->session->userdata('lan')]['alias']))
        $alias = $alias[$this->session->userdata('lan')]['alias'];
    else
        $alias = '';
    
    if(isset($product_name[$this->session->userdata('lan')]['product_name']))
        $product_name = $product_name[$this->session->userdata('lan')]['product_name'];
    else
        $product_name = '';
        if(isset($product_desc[$this->session->userdata('lan')]['product_desc']))
        $product_desc = $product_desc[$this->session->userdata('lan')]['product_desc'];
    else
        $product_desc = '';
    $detail = $this->_global->_unserialize($post->product_detail);
    $color = current($detail['options']['colors']);
    if(!isset($_GET['mode']) || $_GET['mode']=='table'){
?>
<div class="item">
            <div class="price-button"><?php echo $post->price_export?> vnd</div>
                	<?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'<img alt="'.$product_name.'" src="'.$this->config->item('cdn_url').'exec/timthumb.php?src='.base_url().current($color['images']).'&w=175&h=175&zc=1"/>','title="'.$product_name.'"') ?>
                    <h3><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,$product_name) ?></h3>
                    <p>Nhà cung cấp : <strong><?php echo $post->brand_tag; ?></strong></p>
                    <div class="button"><span><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'Xem chi tiết')?></span></div>
            </div>

<?php 
}else{
?>
<ul class="list-item">
    <li><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'<img alt="'.$product_name.'" src="'.$this->config->item('cdn_url').'exec/timthumb.php?src='.base_url().current($color['images']).'&w=175&h=175&zc=1"/>','title="'.$product_name.'"') ?></li>
    <li><h3><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,$product_name) ?></h3>
    <p style="font-weight: bold;padding: 5px 0;"><?php echo $post->price_export?> vnd </p>
    
    <div class="button" style="position: static;"><span><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'Xem chi tiết')?></span></div>
    <p>Nhà cung cấp : <strong><?php echo $post->brand_tag; ?></strong></p>
    <p><?php echo $product_desc ?></p>
    </li>
<div class="clear"></div>
</ul>

<?php
}
endforeach; ?>
<div class="clear">

</div>
<?php
else:
?>
<div><h1 style="padding: 20px 0px;"><?php echo $this->lang->line('notfound') ?></h1></div>
<?php
endif;
?></div>
<?php } ?>
<div class="clear"></div>
